package learn.abstractfactory.now;

import javafx.scene.control.ComboBox;

/**
 * 抽象工厂模式
 *
 * @author 执笔
 * @date 2019/11/26 9:21
 */
public class AbstractFactory {


    // 抽象产品
    interface OrderPay {

        /**
         * 下单
         */
        void order();
    }

    // 具体产品
    class WxOrderPay implements OrderPay {

        public void order() {
            // 微信支付
        }
    }

    // 具体产品
    class ZfbOrderPay implements OrderPay {

        public void order() {
            // 支付宝支付
        }
    }

    // 抽象产品
    interface Authorize {

        void auth();
    }

    // 具体产品
    class WxAuthorize implements Authorize {

        public void auth() {
            // 微信
        }
    }

    // 具体产品
    class ZfbAuthorize implements Authorize {

        public void auth() {
            // 支付宝
        }
    }

    // 抽象工厂
    interface PayFactory {
        OrderPay createOrderPay();

        Authorize createAuthorize();
    }

    // 具体工厂
    class WxFactory implements PayFactory {

        public OrderPay createOrderPay() {
            return new WxOrderPay();
        }

        public Authorize createAuthorize() {
            return new WxAuthorize();
        }
    }

    // 具体工厂
    class ZfbFactory implements PayFactory {

        public OrderPay createOrderPay() {
            return new ZfbOrderPay();
        }

        public Authorize createAuthorize() {
            return new ZfbAuthorize();
        }
    }
}
